function checkLocation(seq) {
	
	str     = eval('document.fabprocess.checkLoc'+seq+'.checked');	
	var cnt = document.fabprocess.count.value;
	var maxVal = 0;
					
	if(cnt!=1)
	{		 
		if(str==false)
		{
			document.fabprocess.priority[seq].disabled=true;
			document.fabprocess.split[seq].disabled=true;
			document.fabprocess.capacityWeek[seq].disabled=true;
			document.fabprocess.normalCost[seq].disabled=true;
			document.fabprocess.expressCost[seq].disabled=true;
			//document.fabprocess.locationName[seq].disabled=true;
			document.fabprocess.normalCycleTime[seq].disabled=true;
			document.fabprocess.expressCycleTime[seq].disabled=true;
			document.fabprocess.expectedYield[seq].disabled=true;

			// added to set the default priority by ravikanth
			maxVal =  document.fabprocess.priority[seq].value;
			for ( var y =0 ; y < cnt ; y++ )
			{
				temp   = document.fabprocess.priority[y].value;
				if( temp > maxVal && maxVal != 0)
				{
					document.fabprocess.priority[y].value = parseInt(document.fabprocess.priority[y].value) -1;
				}
			}

			document.fabprocess.priority[seq].value='';
		}

		if(str==true)
		{
			document.fabprocess.priority[seq].disabled=false;
			document.fabprocess.split[seq].disabled=false;
			document.fabprocess.capacityWeek[seq].disabled=false;
			document.fabprocess.normalCost[seq].disabled=false;
			document.fabprocess.expressCost[seq].disabled=false;
			//document.fabprocess.locationName[seq].disabled=false;
			document.fabprocess.normalCycleTime[seq].disabled=false;
			document.fabprocess.expressCycleTime[seq].disabled=false;
			document.fabprocess.expectedYield[seq].disabled=false;
			
			// added to set the default priority by ravikanth
			for ( var y =0 ; y < cnt ; y++ )
			{
				temp   = document.fabprocess.priority[y].value;
				//alert(temp);
				if( temp > maxVal)
				{
					maxVal = temp
				}
			}		
			document.fabprocess.priority[seq].value= parseInt(maxVal)+1 ;
		}
	}
	else
	{
		if(str==false)
		{
			document.fabprocess.priority.disabled=true;
			document.fabprocess.split.disabled=true;
			document.fabprocess.capacityWeek.disabled=true;
			document.fabprocess.normalCost.disabled=true;
			document.fabprocess.expressCost.disabled=true;
			//document.fabprocess.locationName.disabled=true;
			document.fabprocess.normalCycleTime.disabled=true;
			document.fabprocess.expressCycleTime.disabled=true;
			document.fabprocess.expectedYield.disabled=true;									
			document.fabprocess.priority.value='';
		}
		if(str==true)
		{
			document.fabprocess.priority.disabled=false;
			document.fabprocess.split.disabled=false;
			document.fabprocess.capacityWeek.disabled=false;
			document.fabprocess.normalCost.disabled=false;
			document.fabprocess.expressCost.disabled=false;
			//document.fabprocess.locationName.disabled=false;
			document.fabprocess.normalCycleTime.disabled=false;
			document.fabprocess.expressCycleTime.disabled=false;
			document.fabprocess.expectedYield.disabled=false;
			document.fabprocess.priority.value=1;
		}
	}
}

function whileLoad()
{
	var cnt = document.fabprocess.count.value;
	if(cnt==1)
	{ 
		str     = eval('document.fabprocess.checkLoc0.checked');
		
		if(str==false){
				document.fabprocess.priority.disabled=true;
				document.fabprocess.split.disabled=true;
				document.fabprocess.capacityWeek.disabled=true;
				document.fabprocess.normalCost.disabled=true;
				document.fabprocess.expressCost.disabled=true;
				//document.fabprocess.locationName.disabled=true;
				document.fabprocess.normalCycleTime.disabled=true;
				document.fabprocess.expressCycleTime.disabled=true;
				document.fabprocess.expectedYield.disabled=true;									
				}

				if(str==true){
				document.fabprocess.priority.disabled=false;
				document.fabprocess.split.disabled=false;
				document.fabprocess.capacityWeek.disabled=false;
				document.fabprocess.normalCost.disabled=false;
				document.fabprocess.expressCost.disabled=false;
				//document.fabprocess.locationName.disabled=false;
				document.fabprocess.normalCycleTime.disabled=false;
				document.fabprocess.expressCycleTime.disabled=false;
				document.fabprocess.expectedYield.disabled=false;
				}

	}


	else{

	for(var i=0;i<cnt;i++){
			
				str     = eval('document.fabprocess.checkLoc'+i+'.checked');
						
				if(str==false){
				document.fabprocess.priority[i].disabled=true;
				document.fabprocess.split[i].disabled=true;
				document.fabprocess.capacityWeek[i].disabled=true;
				document.fabprocess.normalCost[i].disabled=true;
				document.fabprocess.expressCost[i].disabled=true;
				//document.fabprocess.locationName[i].disabled=true;
				document.fabprocess.normalCycleTime[i].disabled=true;
				document.fabprocess.expressCycleTime[i].disabled=true;
				document.fabprocess.expectedYield[i].disabled=true;									
				}

				else if(str==true){
				document.fabprocess.priority[i].disabled=false;
				document.fabprocess.split[i].disabled=false;
				document.fabprocess.capacityWeek[i].disabled=false;
				document.fabprocess.normalCost[i].disabled=false;
				document.fabprocess.expressCost[i].disabled=false;
				//document.fabprocess.locationName[i].disabled=false;
				document.fabprocess.normalCycleTime[i].disabled=false;
				document.fabprocess.expressCycleTime[i].disabled=false;
				document.fabprocess.expectedYield[i].disabled=false;
				}
			
	}

	}
	
		
}

function recipe()
{
	
	var cnt = document.fabprocess.count.value;
	if(cnt!=1){
	for(var i=0;i<cnt;i++){
				document.fabprocess.priority[i].disabled=false;
				document.fabprocess.split[i].disabled=false;
				document.fabprocess.capacityWeek[i].disabled=false;
				document.fabprocess.normalCost[i].disabled=false;
				document.fabprocess.expressCost[i].disabled=false;
				document.fabprocess.locationName[i].disabled=false;
				document.fabprocess.normalCycleTime[i].disabled=false;
				document.fabprocess.expressCycleTime[i].disabled=false;
				document.fabprocess.expectedYield[i].disabled=false;
	}
	}

	else{
		document.fabprocess.priority.disabled=false;
		document.fabprocess.split.disabled=false;
		document.fabprocess.capacityWeek.disabled=false;
		document.fabprocess.normalCost.disabled=false;
		document.fabprocess.expressCost.disabled=false;
		document.fabprocess.locationName.disabled=false;
		document.fabprocess.normalCycleTime.disabled=false;
		document.fabprocess.expressCycleTime.disabled=false;
		document.fabprocess.expectedYield.disabled=false;
	    }
	document.fabprocess.action='fabProcessRecipe.do';
	document.fabprocess.submit();
		
}

// changed by hareesh on 15th Setpemeber 2003
//function next(cnt)
function next()
{
	var temp					= document.fabprocess;
	var cnt						= document.fabprocess.count.value;
	var pa						= document.getElementById("message");
	var diePerWafer				= trim(document.fabprocess.gross.value);
	var lot_hold_yield_limit	= trim(document.fabprocess.lotHoldYieldLimit.value);
	var std_unit_cost			= trim(document.fabprocess.standardUnitCost.value);
	var lot_scrap_yield_limit   = trim(document.fabprocess.lotScrapYieldLimit.value);
	var proc_doc_no				= trim(document.fabprocess.procDocNo.value);
	var mask_id_no				= trim(document.fabprocess.maskIdNo.value);
	var target_yield			= trim(document.fabprocess.targetYield.value);
	var vendorCnt				= 0;
	var msg						= '';
	var vendorPriority			=  null;
	
	if(trim(document.fabprocess.fabName.value)=='')
	{
		pa.innerHTML = "FAB Product Name cannot be null or contain spaces ";	
		document.fabprocess.fabName.value=''; 
		document.fabprocess.fabName.focus();
		return;
		//msg = "FAB Product Name cannot be null or contain spaces \n\r"
	}
	else
	{
		document.fabprocess.fabName.value = document.fabprocess.fabName.value.trim(); 
	}

	if( typeof document.fabprocess.locationName.length == 'undefined' )
	{
		if ( document.fabprocess.checkLoc0.checked+"" == "true" )
		{
			vendorCnt++;
		}	
		if( vendorCnt > 0 && ( document.fabprocess.priority.value =='0' || document.fabprocess.priority.value.trim().length == 0 ) )
		{
			pa.innerHTML = "Priority cannot 0 or empty ";	
			document.fabprocess.priority.value='';
			document.fabprocess.priority.focus();
			return; 
		}
	}
	else
	{
		vendorPriority = new Array(document.fabprocess.locationName.length);
		for (var x=0 ; x < document.fabprocess.locationName.length ; x++ )
		{
			var temp = eval("document.fabprocess.checkLoc"+x);
			if( temp.checked+"" == "true" )
			{
				vendorCnt++;
				if (document.fabprocess.priority[x].value == 0 || document.fabprocess.priority[x].value.trim().length == 0 )
				{
					
					pa.innerHTML = "Vendor priority cannot 0 or empty ";	
					document.fabprocess.priority[x].value = '';
					document.fabprocess.priority[x].focus();
					return; 
				}
				vendorPriority[x] = document.fabprocess.priority[x].value
			}
		}

		
		if( vendorCnt > 1 )
		{
			
			for ( y=0 ; y < vendorPriority.length -1 ; y++ )
			{
				for ( z = y+1 ; z < vendorPriority.length ; z++ )
				{
					if( vendorPriority[y] != null && vendorPriority[z] != null && vendorPriority[y] != 0 && vendorPriority[z] !=0 )
					{
						if ( vendorPriority[z] == vendorPriority[y])
						{
							pa.innerHTML = "Two vendor priorities cannot be same ";	
							return; 
						}
					}
				}
			}
		}
	}

	if( vendorCnt == 0)
	{
		//msg = msg + "Should select atleast one vendor \n\r"
		pa.innerHTML = "Should select atleast one vendor";	
		return; 
	}
	
	var flag = checkDupInProduct(document.fabprocess.fabName,document.fabprocess.dupProductName);
	if( flag != -1 )
	{
		if( typeof document.fabprocess.dupProductName.length == 'undefined' )
		{
			document.fabprocess.dupProductName.focus();
		}
		else
		{
			document.fabprocess.dupProductName[flag].focus();	
		}
		pa.innerHTML = "Two Part numbers cannot be same";	
		return; 
		//msg = msg + "Two Part numbers cannot be same \n\r"
	}

	
		
	// check for duplicate names here
	/*if(temp.dupFabName != null)
	{
		if( typeof temp.dupFabName.length == 'undefined' )
		{
			temp.dupFabName.value = trim(temp.dupFabName.value);
			if(temp.fabName.value == temp.dupFabName.value)
			{
				pa.innerHTML = "Two Part numbers cannot be same";	
				temp.dupFabName.focus();
				return;
			}
		}
		else
		{
			for( var x=0; x < temp.dupFabName.length; x++ )
			{
				temp.dupFabName[x].value = trim(temp.dupFabName[x].value);
				if(trim(temp.dupFabName[x].value)!='' && temp.fabName.value == temp.dupFabName[x].value)
				{
					pa.innerHTML = "Two Part numbers cannot be same";	
					temp.dupFabName[x].focus();
					return;
				}							
			}
			
			for( var x=0; x < temp.dupFabName.length-1; x++ )
			{
				for( var y = x+1; y < temp.dupFabName.length; y++ )
				{
					if(trim(temp.dupFabName[x].value)!='' && trim(temp.dupFabName[y].value)!='' && temp.dupFabName[x].value == temp.dupFabName[y].value)
					{
						pa.innerHTML = "Two Part numbers cannot be same";	
						temp.dupFabName[y].focus();
						return;
					}
				}
			}
		}
	} */
	
	if(diePerWafer!=''){
		if (!isInteger(diePerWafer)){
		pa.innerHTML = "Please enter valid Gross Die Per Wafer,It must be number";	
		return;
		}
	}

	if(lot_hold_yield_limit!=''){
		if(!isFloat(lot_hold_yield_limit)){	
 	    pa.innerHTML = "Please enter valid Lot Hold Yield Limit,It must be float";
		document.fabprocess.lotHoldYieldLimit.select();
		document.fabprocess.lotHoldYieldLimit.focus();
		return;
		}	
	}

	if(std_unit_cost!=''){
		if(!isFloat(std_unit_cost)){	
 	    pa.innerHTML = "Please enter valid Standard Unit Cost,It must be float";
		document.fabprocess.standardUnitCost.select();
		document.fabprocess.standardUnitCost.focus();
		return;
		}	
	}

	if(lot_scrap_yield_limit!=''){
		if(!isFloat(lot_scrap_yield_limit)){	
 	    pa.innerHTML = "Please enter valid Lot Scrap Yield Limit,It must be float";
		document.fabprocess.lotScrapYieldLimit.select();
		document.fabprocess.lotScrapYieldLimit.focus();
		return;
		}	
	}

	if(target_yield!=''){
		if(!isFloat(target_yield)){	
 	    pa.innerHTML = "Please enter valid Target Yield,It must be Float";
		document.fabprocess.targetYield.select();
		document.fabprocess.targetYield.focus();
		return;
		}	
	}



	if(cnt==1)
	{ 
		str     = eval('document.fabprocess.checkLoc0.checked');
		
				if(str==true){
                var priority		= trim(document.fabprocess.priority.value);
				var split			= trim(document.fabprocess.split.value);
				var capacity_week   = trim(document.fabprocess.capacityWeek.value);
				var normal_cost		= trim(document.fabprocess.normalCost.value);
				var express_cost	= trim(document.fabprocess.expressCost.value);
				var normal_time		= trim(document.fabprocess.normalCycleTime.value);
				var express_time	= trim(document.fabprocess.expressCycleTime.value);
				var yield			= trim(document.fabprocess.expectedYield.value);

				document.fabprocess.priority.value				= trim(document.fabprocess.priority.value);
				document.fabprocess.split.value					= trim(document.fabprocess.split.value);
				document.fabprocess.capacityWeek.value			= trim(document.fabprocess.capacityWeek.value);
				document.fabprocess.normalCost.value			= trim(document.fabprocess.normalCost.value);
				document.fabprocess.expressCost.value			= trim(document.fabprocess.expressCost.value);
				document.fabprocess.normalCycleTime.value		= trim(document.fabprocess.normalCycleTime.value);
				document.fabprocess.expressCycleTime.value		= trim(document.fabprocess.expressCycleTime.value);
				document.fabprocess.expectedYield.value			= trim(document.fabprocess.expectedYield.value);
		
				

				if(priority!=''){
				if (!isInteger(priority)){
				pa.innerHTML = "Please enter valid Priority,It must be number";
				document.fabprocess.priority.select();
				document.fabprocess.priority.focus();
				return;
				}
				}

				if(split!=''){
				if (!isFloat(split)){
				pa.innerHTML = "Please enter valid Split,It must be float";
				document.fabprocess.split.select();
				document.fabprocess.split.focus();
				return;
				}
				}

				if(capacity_week!=''){
				if (!isInteger(capacity_week)){
				pa.innerHTML = "Please enter valid Capacity Per Week,It must be number";
				document.fabprocess.capacityWeek.select();
				document.fabprocess.capacityWeek.focus();
				return;
				}
				}

				if(normal_cost!=''){
				if (!isFloat(normal_cost)){
				pa.innerHTML = "Please enter valid Normal Cost,It must be float";
				document.fabprocess.normalCost.select();
				document.fabprocess.normalCost.focus();
				return;
				}
				}

				if(express_cost!=''){
				if (!isFloat(express_cost)){
				pa.innerHTML = "Please enter valid Express Cost,It must be float";
				document.fabprocess.expressCost.select();
				document.fabprocess.expressCost.focus();
				return;
				}
				}

				if(normal_time!=''){
				if (!isInteger(normal_time)){
				pa.innerHTML = "Please enter valid Normal Time,It must be number";
				document.fabprocess.normalCycleTime.select();
				document.fabprocess.normalCycleTime.focus();
				return;
				}
				}

				if(express_time!=''){
				if (!isInteger(express_time)){
				pa.innerHTML = "Please enter valid Express Time,It must be number";
				document.fabprocess.expressCycleTime.select();
				document.fabprocess.expressCycleTime.focus();
				return;
				}
				}

				if(yield!=''){
				if (!isFloat(yield)){
				pa.innerHTML = "Please enter valid Expected yield,It must be float";
				document.fabprocess.expectedYield.select();
				document.fabprocess.expectedYield.focus();
				return;
				}
				}

			}

	}


	else{
		
	for(var i=0;i<cnt;i++){
			
				str     = eval('document.fabprocess.checkLoc'+i+'.checked');
				
				if(str==true){
				var priority		= trim(document.fabprocess.priority[i].value);
				var split			= trim(document.fabprocess.split[i].value);
				var capacity_week   = trim(document.fabprocess.capacityWeek[i].value);
				var normal_cost		= trim(document.fabprocess.normalCost[i].value);
				var express_cost	= trim(document.fabprocess.expressCost[i].value);
				var normal_time		= trim(document.fabprocess.normalCycleTime[i].value);
				var express_time	= trim(document.fabprocess.expressCycleTime[i].value);
				var yield			= trim(document.fabprocess.expectedYield[i].value);

				document.fabprocess.priority[i].value			= trim(document.fabprocess.priority[i].value);
				document.fabprocess.split[i].value				= trim(document.fabprocess.split[i].value);
				document.fabprocess.capacityWeek[i].value		= trim(document.fabprocess.capacityWeek[i].value);
				document.fabprocess.normalCost[i].value			= trim(document.fabprocess.normalCost[i].value);
				document.fabprocess.expressCost[i].value		= trim(document.fabprocess.expressCost[i].value);
				document.fabprocess.normalCycleTime[i].value	= trim(document.fabprocess.normalCycleTime[i].value);
				document.fabprocess.expressCycleTime[i].value	= trim(document.fabprocess.expressCycleTime[i].value);
				document.fabprocess.expectedYield[i].value		= trim(document.fabprocess.expectedYield[i].value);

		
				if(priority!=''){
				if (!isInteger(priority)){
				pa.innerHTML = "Please enter valid Priority,It must be number";
				document.fabprocess.priority[i].select();
				document.fabprocess.priority[i].focus();
				return;
				}
				}

				if(split!=''){
				if (!isFloat(split)){
				pa.innerHTML = "Please enter valid Split,It must be float";
				document.fabprocess.split[i].select();
				document.fabprocess.split[i].focus();
				return;
				}
				}

				if(capacity_week!=''){
				if (!isInteger(capacity_week)){
				pa.innerHTML = "Please enter valid Capacity Per Week,It must be number";
				document.fabprocess.capacityWeek[i].select();
				document.fabprocess.capacityWeek[i].focus();
				return;
				}
				}

				if(normal_cost!=''){
				if (!isFloat(normal_cost)){
				pa.innerHTML = "Please enter valid Normal Cost,It must be float";
				document.fabprocess.normalCost[i].select();
				document.fabprocess.normalCost[i].focus();
				return;
				}
				}

				if(express_cost!=''){
				if (!isFloat(express_cost)){
				pa.innerHTML = "Please enter valid Express Cost,It must be float";
				document.fabprocess.expressCost[i].select();
				document.fabprocess.expressCost[i].focus();
				return;
				}
				}

				if(normal_time!=''){
				if (!isInteger(normal_time)){
				pa.innerHTML = "Please enter valid Normal Time,It must be number";
				document.fabprocess.normalCycleTime[i].select();
				document.fabprocess.normalCycleTime[i].focus();
				return;
				}
				}

				if(express_time!=''){
				if (!isInteger(express_time)){
				pa.innerHTML = "Please enter valid Express Time,It must be number";
				document.fabprocess.expressCycleTime[i].select();
				document.fabprocess.expressCycleTime[i].focus();
				return;
				}
				}

				if(yield!=''){
				if (!isFloat(yield)){
				pa.innerHTML = "Please enter valid Expected yield,It must be float";
				document.fabprocess.expectedYield[i].select();
				document.fabprocess.expectedYield[i].focus();
				return;
				}
				}

				}
				
	}

	}
	

	if(cnt!=1){
	for(var i=0;i<cnt;i++){
				document.fabprocess.priority[i].disabled=false;
				document.fabprocess.split[i].disabled=false;
				document.fabprocess.capacityWeek[i].disabled=false;
				document.fabprocess.normalCost[i].disabled=false;
				document.fabprocess.expressCost[i].disabled=false;
				document.fabprocess.locationName[i].disabled=false;
				document.fabprocess.normalCycleTime[i].disabled=false;
				document.fabprocess.expressCycleTime[i].disabled=false;
				document.fabprocess.expectedYield[i].disabled=false;
	}
	}

	else{
		document.fabprocess.priority.disabled=false;
		document.fabprocess.split.disabled=false;
		document.fabprocess.capacityWeek.disabled=false;
		document.fabprocess.normalCost.disabled=false;
		document.fabprocess.expressCost.disabled=false;
		document.fabprocess.locationName.disabled=false;
		document.fabprocess.normalCycleTime.disabled=false;
		document.fabprocess.expressCycleTime.disabled=false;
		document.fabprocess.expectedYield.disabled=false;
	    }
	document.fabprocess.action='fabAction.do?action=save';
	document.fabprocess.submit();
		
}

// added by ravikanth on 15 Sep 2003
/*function addDupPartNumber()
{
    var htmltext = '<table style=NArialL cellspacing=0 cellpadding=0 width="100%" border=0><tr><td width="21%"><font class="NArialL"><font color=green>FAB Product Name:</font></font></td><td width="28%"><input type=text name="dupFabName" class=txfield size="17" maxlength="50" /></td><td colspan=4></td></tr></table>';
    var pa1 = document.getElementById ("font1");
    pa1.insertAdjacentHTML ('BeforeEnd',htmltext);

}*/